import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: xiaotutu
 * Date: 2023-12-16
 * Time: 14:22
 */


/*public class Config {
    File file;
    // public void OpenConfig(String filename) throws IOException,FileNotFoundException{
// FileNotFoundException 继承自 IOException
    public void OpenConfig(String filename) throws IOException {
        if(filename.endsWith(".ini")){
            throw new IOException("文件不是.ini文件");
        }
        if(filename.equals("config.ini")){
            throw new FileNotFoundException("配置文件名字不对");
        }
// 打开文件
    }
    public void readConfig(){
    }
}

    public static void main(String[] args) throws IOException {
        Config config = new Config();
        config.openConfig("config.ini");
    }
}*/
/*
class Config {
    File file;
    *//*
    FileNotFoundException : 编译时异常，表明文件不存在
    此处不处理，也没有能力处理，应该将错误信息报告给调用者，让调用者检查文件名字是否给错误了
    *//*
    public void OpenConfig(String filename) throws FileNotFoundException{
        if(filename.equals("config.ini")){
            throw new FileNotFoundException("配置文件名字不对");
        }
    // 打开文件
    }
    public void readConfig(){
    }
}*/


class Person {
    private String name;
    private String gender;
    private int age;

    @Override
    protected Object clone() throws CloneNotSupportedException {
        return super.clone();
    }
}

public class Test {


    public static void main1(String[] args) {
        Person person1 = new Person();
        try {
            Person person2 = (Person) person1.clone();
        }catch (CloneNotSupportedException e) {
            System.out.println("无法克隆");
        }
    }




    public static int getElement(int[] array, int index){
        if(null == array){
             throw new NullPointerException("传递的数组为null");

        }
        if(index < 0 || index >= array.length){
            throw new ArrayIndexOutOfBoundsException("传递的数组下标越界");
        }
        return array[index];
    }
    public static void main(String[] args) {
        int[] array = {1,2,3};
        getElement(array, 3);
    }

}
